package com.example.ecity.myimagebutton;

import android.content.Context;
import android.util.Log;

public class ButtonManager{
	private static final String TAG = "ButtonManager";
	
	private int ScreenWidth;
	private int ScreenHeight;
	
	public ButtonManager(Context context){
		super();
	}
	
	public void screenSize(int width,int height){
		this.ScreenWidth = width;
		this.ScreenHeight = height;
	}
	
	public int GetScreenWidth(){
		return ScreenWidth;
	}
	public int GetScreenHeight(){
		return ScreenHeight;
	}
	
	public int buttonPositionX(double azimuthOfPhone,double azimuthOfPoi){
		int result = -1;
		double angle = 0;
		if(azimuthOfPhone < 360 - 80 - 50 ){
			angle = azimuthOfPoi - azimuthOfPhone;
			if(angle > 50 && angle < 130){
				result = (int) ((angle - 50) * ScreenWidth / 80);
			}
		}else if(azimuthOfPhone > 230 && azimuthOfPhone < 360){
			if(azimuthOfPoi > azimuthOfPhone){
				angle = azimuthOfPoi - azimuthOfPhone;
				if(angle > 50 && angle < 130){
					result = (int) ((angle - 50) * ScreenWidth / 80);
				}
			}else if(azimuthOfPoi < 130){
				angle = azimuthOfPoi + 360 - azimuthOfPhone;
				if(angle > 50 && angle < 130){
					result = (int) ((angle - 50) * ScreenWidth / 80);
				}
			}
		}
		return result;
	}
	
	public int buttonPositionY(double distance){
		return (int)(ScreenHeight - distance*ScreenHeight);
	}
}